<template>
    <div :style="{height:'212px',width:'100%'}" ref="myEchart">
    </div>
</template>
<script>
    import echarts from "echarts";
    export default {
        mounted() {
            this.drawLine();
        },
        props:{
            lineData: {
                defaults: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            }
        },
        methods: {
            drawLine() {
                // 基于准备好的dom，初始化echarts实例
                let myChart = echarts.init(this.$refs.myEchart);
                // 绘制图表
                myChart.setOption({
                    grid: {
                        left: 28,
                        right: 14,
                        top: 10,
                    },
                    backgroundColor: "rgba(0,0,0,0.0)",
                    tooltip: {},
                    // title: { text: '年度出差记录' , top: '5%' ,left: ' 3%' },
                    xAxis: {
                        data: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
                        axisLabel: {
                            formatter: function(value) {
                                return value.split("").join("\n");
                            }
                        },
                    },
                    yAxis: {},
                    series: [{
                        name: '出差次数',
                        type: 'bar',
                        data: this.lineData,
                        itemStyle: {
                            normal: {
                                color: '#4084AF'
                            }
                        },
                    }],
                });
            }
        }
    }
</script>